#include <bits/stdc++.h>
using namespace std;

#define MAX 200200

int n, m, ans;
int f[MAX];

int getf(int x) { return x == f[x] ? x : f[x] = getf(f[x]); }

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i)
    f[i] = i;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    if (getf(u) == getf(v))
      ++ans;
    else
      f[getf(u)] = getf(v);
  }
  printf("%d\n", ans);
  return 0;
}
